/*
 * This class contain all Abstract Actions of the Menubar, </br>
 * where each action calls to a function in GblModel which contain </br>
 * their action.
 */
package gbl;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;


/**
 * This class contains and executes the abstract actions of the menubar.
 * @since 1.7
 * @version 1.7 
 * @author Solveig </br>
 * Last modified by Solveig, 28/09/11
 */
public class GblMenubarAbstracts {
	// Objects and variables:
	private GblModel gblm;
	
	
	/**
	    * Constructor. Get gblm class from gbl.java.
	    * @param GblModel getgblm
	    * @since 1.7
	    * @version 1.7
	    * @author Solveig </br>
	    * Last modified by Solveig, 28/09/11
	    */
	public GblMenubarAbstracts(GblModel getgblm){
		gblm = getgblm;
	}



   /**
    * Function called by gbl.java. </br>
    * Contains all abstract actions for all items under "file" in the menu.
    * @param JMenuItem fileNew, fileLoad, fileSave, fileSaveTo, filePreview.
    * @param JMenuItem fileGenerate, fileExit.
    * @since 1.7
    * @version 1.8
    * @author Solveig		</br>
    * Last modified by Solveig, 28/09/11
    */
   public void fileActionlisteners(JMenuItem fileNew, JMenuItem fileLoad, JMenuItem fileSave, 
 		  JMenuItem fileSaveTo, JMenuItem filePreview, JMenuItem fileGenerate, JMenuItem fileExit){
 	  
	   // ActionListener for fileNew:
	  fileNew.addActionListener(new ActionListener(){
 		 public void actionPerformed(ActionEvent ae){
 			 gblm.tableNewfile();
 		 }
 	  });	  
 	  
	  // ActionListener for fileLoad:
 	  fileLoad.addActionListener(new ActionListener(){
 		 public void actionPerformed(ActionEvent ae){
 			 gblm.tableLoadfile();
 		 }
 	  });
 	  
 	  // ActionListener for fileSave:
 	  fileSave.addActionListener(new ActionListener(){
 		 public void actionPerformed(ActionEvent ae){
 			 gblm.tableSavefile();
 		 }
 	  });
 	  
 	  // ActionListener for fileSaveTo
 	  fileSaveTo.addActionListener(new ActionListener(){
 		 public void actionPerformed(ActionEvent ae){
 			 gblm.tableSaveAs();
 		 }
 	  });
 	  
 	  // ActionListener for filePreview. NOTE: Not implemented!
 	  /*filePreview.addActionListener(new ActionListener(){
 		 public void actionPerformed(ActionEvent ae){
 			 gblm.tablePreviewfile();
 		 }
 	  });*/
 	  
 	  // ActionListener for fileGenerate:
 	  fileGenerate.addActionListener(new ActionListener(){
 		 public void actionPerformed(ActionEvent ae){
 			 gblm.tableGeneratefile();
 		 }
 	  });
 	  
 	  // ActionListener for fileExit:
 	  fileExit.addActionListener(new ActionListener(){
 		 public void actionPerformed(ActionEvent ae){
 			gblm.tableExitfile();
 		 }
 	  });
   } // end fileActionlisteners(...).
   
   
   
   /**
    * Function called by gbl.java. </br>
    * Contains all abstract actions for all items under "edit" in the menu.
    * @param JMenuItem editNewRow, editPreferences.
    * @since 1.7
    * @version 1.9
    * @author Solveig		</br>
    * Last modified by Solveig, 28/09/11
    */
   public void editActionlisteners(JMenuItem editNewRow, JMenuItem editPreferences){
	   // ActionListener for editNewRow:
 	  editNewRow.addActionListener(new ActionListener(){
     	  public void actionPerformed(ActionEvent ae){
     		 gblm.tableAddrow();
     	  }
       });
 	  
 	  // ActionListener for editPreferences: NOTE: Not implemented!
 /*	  editPreferences.addActionListener(new ActionListener(){
     	  public void actionPerformed(ActionEvent ae){
     		  gblm.tableEditpreferences();
     	  }
       });*/
   }
   
   
   
   /**
    * Function called by gbl.java. </br>
    * Contains all abstract actions for all items under "help" in the menu.
    * @param JMenuItem helpHelp, helpAbout.
    * @since 1.7
    * @version 1.9
    * @author Solveig		</br>
    * Last modified by Solveig, 28/09/11
    */
   public void itemActionlisteners(JMenuItem helpHelp, JMenuItem helpAbout){
	   // ActionListener for helpHelp:
 	  helpHelp.addActionListener(new ActionListener(){
 		  public void actionPerformed(ActionEvent ae){
 			 gblm.tableHelp();
 		  }
 	  });
 	  
 	  // ActionListener for helpAbout:
 	  helpAbout.addActionListener(new ActionListener(){
 		  public void actionPerformed(ActionEvent ae){
 			 gblm.tableAboutgbl();
 		  }
 	  });
   } // end itemActionlisteners(...).
   
   
   
	   
	
	
	
	
}
